"""
curl -H "Accept: application/json" -H "Content-type: application/json"  -X POST http://192.168.5.233/v2/edoc/ocr/recognize/ -d '{
  "layout":{"header": null, "footer": null, "column_count": 1, "pos": null, "box": [0, 0, 687, 634], "contents": [],
   "gutter": {"pos": "", "x": 0}, "columns": [[0, 0, 687, 634]]},
  "urls":[
    "https://s.100tifen.com/media/uploads/2022/1220/988i1lb7b8.jpg"
  ]
}'
"""
import time

import requests


_data = [
    {
        'uri': 'https://demo-1251808174.cos.ap-chengdu.myqcloud.com/media/edoc/common/2024-06/2771/img_2.webp?imageMogr2/rotate/90|imageMogr2/cut/967.3381118833562x1414.8541272798986x23.8414645524149x73.18731100627365',
        'query': 'imageMogr2/rotate/90|imageMogr2/cut/967.3381118833562x1414.8541272798986x23.8414645524149x73.18731100627365',
        'str_rotate': '?imageMogr2/rotate/90',
        'cut': [967.3381118833562, 1414.8541272798986, 23.8414645524149, 73.18731100627365]},
    # {
    #     'uri': 'https://demo-1251808174.cos.ap-chengdu.myqcloud.com/media/edoc/common/2024-06/2771/img_2.webp?imageMogr2/rotate/90|imageMogr2/cut/928.2537437264527x1408.9914720563631x1014.630197329913x81.0041846376543',
    #     'query': 'imageMogr2/rotate/90|imageMogr2/cut/928.2537437264527x1408.9914720563631x1014.630197329913x81.0041846376543',
    #     'str_rotate': '?imageMogr2/rotate/90',
    #     'cut': [928.2537437264527, 1408.9914720563631, 1014.630197329913, 81.0041846376543]
    # }
]

# _uri = 'http://192.168.5.233/v2/edoc/ocr/recognize/'
_uri = 'http://127.0.0.1:7001/recognize/'
# _uri = 'http://192.168.5.51:7001/recognize/'
headers = {
    "Accept": "application/json",
    "Content-type": "application/json",
}
data = {'layout': {'column_count': 2,
                   'columns': [[23.8414645524149, 73.18731100627365, 967.3381118833562, 1414.8541272798986], [1014.630197329913, 81.0041846376543, 928.2537437264527, 1408.9914720563631]]},
        'urls': ['https://demo-1251808174.cos.ap-chengdu.myqcloud.com/media/edoc/common/2024-06/2771/img_2.webp?imageMogr2/rotate/90'],
        'is_sort':True

        }

# pprint(dict(url=_uri, json=data, headers=headers))
time1 = time.time()
x = requests.post(_uri, json=data, headers=headers)
print(x.content)
print(x.json())
print(time.time() - time1)


